package com.example.activity;

import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    //数据传递
    private EditText et_Phone;
    private EditText et_Number;
    private EditText et_Password;
    private Button btn_login;

    //生命周期方法
    //onCreate()方法
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Log.i("MainActivityLife", "调用onCreate()");


        //数据传递
        et_Phone = (EditText) findViewById(R.id.et_phone);
        et_Number = (EditText) findViewById(R.id.et_number);
        et_Password = (EditText) findViewById(R.id.et_password);
        btn_login = (Button) findViewById(R.id.btn_login);
        //点击开始按钮进行数据传递
        btn_login.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                passDate();
            }
        });
    }
    //传递数据
    public void passDate() {
        //创建Intent对象
        Intent intent = new Intent(this,ShowActivity.class);
        //将数据存入Intent值
        intent.putExtra("phone",et_Phone.getText().toString().trim());
        intent.putExtra("number",et_Number.getText().toString().trim());
        intent.putExtra("passward",et_Password.getText().toString().trim());
        startActivity(intent);
    }


    //onStart()方法
    @Override
    protected void onStart(){
        super.onStart();
        Log.i("MainActivityLife","调用onStart()");
    }

    //onResume()方法
    @Override
    protected void onResume(){
        super.onResume();
        Log.i("MainActivityLife","调用onResume()");
    }

    //onPause()方法
    @Override
    protected void onPause(){
        super.onPause();
        Log.i("MainActivityLife","调用onPause()");
    }

    //onStop()方法
    @Override
    protected void onStop(){
        super.onStop();
        Log.i("MainActivityLife","调用onStop()");
    }

    //onDestroy方法()
    @Override
    protected void onDestroy(){
        super.onDestroy();
        Log.i("MainActivityLife","调用onDestory()");
    }

    //onRestart()方法
    @Override
    protected void onRestart(){
        super.onRestart();
        Log.i("MainActivityLife","调用onRestart()");
    }


}